# coding:utf-8
# author:frank
# date:2024/12/31
import random

import pygame

pygame.init()

win_w=500
win_h=600
win = pygame.display.set_mode((win_w,win_h))
pygame.display.set_caption("事件检测")
win.fill('white')
pygame.display.flip()

is_down = False
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            exit()
        elif event.type == pygame.MOUSEMOTION:
            print("鼠标移动")
            if is_down:
                r = random.randint(0,255)
                g = random.randint(0,255)
                b = random.randint(0,255)
                pygame.draw.circle(win,(r,g,b),event.pos,20)
                pygame.display.update()
        elif event.type == pygame.MOUSEBUTTONDOWN:
            print("鼠标按下")
            is_down = True
        elif event.type == pygame.MOUSEBUTTONUP:
            print("鼠标松开")
            is_down = False
        elif event.type == pygame.MOUSEWHEEL:
            print("鼠标滚轮")